package logic

import (
	"ginmt/pkg"
	"github.com/gin-gonic/gin"
	"github.com/silenceper/wechat/v2/officialaccount/js"
)

type WebChatLogic struct {
	AppCtx *pkg.AppCtx
	ctx    *gin.Context
}

func NewWebChatLogic(appCtx *pkg.AppCtx, ctx *gin.Context) *WebChatLogic {
	return &WebChatLogic{
		appCtx,
		ctx,
	}
}

func (w *WebChatLogic) GetJsConfig(uri string) (*js.Config, error) {
	w.AppCtx.Wechat.OfficialAccount.GetContext()
	wechatJs := w.AppCtx.Wechat.OfficialAccount.GetJs()
	return wechatJs.GetConfig(uri)
}
